package WaiBao;

import java.util.Arrays;

public class LiSuYa {
    public static void main(String[] args) {
        String[] name = {"武松(班长)", "松江(副班长)", "小李(学习委员)", "李道华(文艺委员)", "韩愈", "欧阳", "诸葛亮", "诸葛瑾", "曹操", "孙权", "周瑜", "姜子牙",
                "貂蝉", "林俊杰", "华晨宇", "周深", "韩海", "李玉", "张玉龙", "小虎", "李志远", "白敬亭", "赵赫", "安龙", "曾志伟", "冯小刚", "张国立", "佟大为",
                "王源", "李苏亚(学生)"};//考生本人: 李苏亚(学生) 学号:210813021111
        int[] age = {18, 19, 18, 21, 20, 21, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 18, 20};//最后一位：考生年龄:20


        double[] soon1 = {84, 72, 81, 80, 79, 69, 78, 89, 80, 80, 91, 87, 85, 89, 65, 68, 99, 99, 94, 88, 92, 91, 91, 65, 75, 74, 94, 74, 88, 95};
        double[] soon2 = {64, 78, 79, 91, 74, 74, 78, 69, 91, 67, 90, 77, 66, 95, 65, 65, 76, 79, 66, 98, 72, 71, 95, 81, 75, 88, 84, 64, 80, 95};
        double[] soon3 = {81, 76, 84, 84, 77, 66, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 95, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 95};


        double bajiao1;//代表每个学生的总分
        double bajiao2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            bajiao1 = soon1[i] + soon2[i] + soon3[i];
//            bajiao2 = (bajiao1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + bajiao1);
//            System.out.println(name[i] + "的平均分为:" + bajiao2);
//        }



        double yaunqi = 0, shengling = 0;
//        double[] cuizi = new double[30];
//        for (int i = 0; i < 30; i++) {
//            yaunqi = soon1[i] + soon2[i] +soon3[i];
//            shengling = (yaunqi * 1.0) / 3;
//            cuizi[i] = shengling;
//        }
//
//        for (int i = 0; i < cuizi.length - 1; i++) {
//            for (int j = 0; j < cuizi.length - i - 1; j++) {
//                if (cuizi[j] < cuizi[j + 1]) {
//                    double tep = cuizi[j];
//                    cuizi[j] = cuizi[j + 1];
//                    cuizi[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(cuizi[i]);
//        }


        double kong1 = 0,kong2 = 0, kong3 = 0;//计算每门课的平均分
        double xun1 = 0, xun2 = 0,xun3 = 0;//计算每门课标准差
        double sun1 = 0,sun2 = 0, sun3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <soon1.length; i++) {
            he += soon1[i];
        }
        kong1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + kong1);
        double Sum = 0;
        for (int i = 0; i < soon2.length; i++) {
            Sum += soon2[i];
        }
        kong2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + kong2);
        double sum = 0;
        for (int i = 0; i < soon3.length; i++) {
            sum += soon3[i];
        }
        kong3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" + kong3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < soon1.length; i++) {
            c1 += (soon1[i] - kong1) * (soon1[i] -kong1);
        }
        xun1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + xun1);
        for (int i = 0; i < soon2.length; i++) {
            c2 += (soon2[i] - kong2) * (soon2[i] - kong2);
        }
        xun2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + xun2);

        for (int i = 0; i < soon3.length; i++) {
            c3 += (soon3[i] - kong3) * (soon3[i] - kong3);
        }
        xun3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + xun3);
//////
////
////
//        Arrays.sort(soon1);
//        Arrays.sort(soon2);
//        Arrays.sort(soon3);
//        sun1 = (soon1[14] + soon2[15]) * 1.0 / 2;
//        sun2 = (soon2[14] + soon2[15]) * 1.0 / 2;
//        sun3 = (soon3[14] + soon3[15]) * 1.0 / 2;
//        System.out.println("生物化学的中位数为:" + sun1);
//        System.out.println("物理化学的中位数为:" + sun2);
//        System.out.println("电子与电工技术的中位数为:" + sun3);






    }
}
